<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../../../inc/conn.asp"-->
<!--#include file="../common/u.asp"-->
<%links="order"%>
<%
urlid=checkstr(inHTML(request("id")))
if urlid=""  then
response.Write("<script>window.location.href='/';</script>")
response.End()
else 
set rs=server.CreateObject("adodb.recordset")
sql="select * from orderlist where [order]='"&urlid&"'"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.Write("<script>window.location.href='/';</script>")
response.End
else
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>代购订单</title>
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<script type="text/javascript" src="/js/jquery.min.js"></script>
</head>
<body>

<!--#include file="../../common/top.asp"-->




<div class="fullwidth">
	<div class="place ">
		<a href="/">首页</a> &gt; <a href="/user">会员中心</a> &gt; 代购订单
	</div>
</div>
<!--main-->
<div class="fullwidth bg1">
	<div class="main">
		
		
        
        <!--#include file="../common/left.asp"-->
        
        
		
		<div class="right_show f_r">
			<div class="title_4">
				<h2>代购订单</h2><div></div>
			</div>
			
			<!--<p class="tip">
				本次的付款您将获得<font class="red">10点</font>积分
			</p>-->
			<div class="clear20"></div>
			
			<div class="sure_pay">
				<form action="" method="">
					<table class="stable stable_1">
						<tr>
							<td class="select_td_1">订单 / 包裹</td>
							<td><a href="/user/order/detail/<%=rs("order")%>" class="order_num"><%=rs("order")%></a></td>
						</tr>
						<tr>
							<td class="select_td_1">总费用</td>
							<td><font class="red"><%=formatNumber(CDBL(rs("Money"))*CDBL(rs("rate")),2,-1)%> RMB</font></td>
						</tr>
						<tr>
							<td class="select_td_1">账户余额</td>
							<td><font class="red"><%=formatNumber(money,2,-1)%> RMB</font><a href="#" class="recharge">立即充值</a></td>
						</tr>
					</table>
				  <div class="clear20"></div>
					<div class="sure_btn sure_btn_1">
						<a href="?pay=yes" class="success_btn">确认付款</a>
					</div>
				</form>
			</div>
		</div>
		
		
	</div>
</div>

<div class="clear"></div>


<!--#include file="../../common/footer.asp"-->



<%
if request.QueryString("pay")="yes" then

      '判断余额是否满足
	  if (cdbl(money)-cdbl(CDBL(rs("Money"))*CDBL(rs("rate"))))<0 then
	  response.Write "<div class=""pop_content"">余额不足，<a href=""javascript:adClick('/user/money/recharge', '/user/order/payment/"&rs("order")&"');"">去充值</a></div><div class=""pop_bg""></div>"
	  response.end 
	  end if
	  
	  '扣除余额
	  conn.execute("update [user] set money=money-"&cdbl(CDBL(rs("Money"))*CDBL(rs("rate")))&" where uid='"&uid&"'") 
	  
	  '写入资金明细
	  set rsx=server.createobject("adodb.recordset")
	  sql="select * from funds" 
	  rsx.open sql,conn,1,3
	  rsx.addnew  
	  rsx("Uid")=uid
	  rsx("money")="-"&cdbl(CDBL(rs("Money"))*CDBL(rs("rate")))
	  rsx("Balance")=cdbl(money)-cdbl(CDBL(rs("Money"))*CDBL(rs("rate")))
	  rsx("content")=rs("order")&"付款"
	  rsx("Type")=1
	  rsx("PayType")=2
	  rsx("mark")=1
	  rsx.update
	  rsx.close
	  set rsx=nothing
	  
	  '订单状态更改
	  conn.execute("update orderlist set flag=1 where [order]='"&rs("order")&"'") 
	  conn.execute("update orderdetail set mark=3 where [order]='"&rs("order")&"'") 
	  
	  response.write"<script language=JavaScript>{window.alert('支付完成！');window.location.href='/user/order/detail/"&rs("order")&"';}</script>"

end if



end if
rs.close
set rs=nothing
end if
%>
</body>
</html>